<template>
	<view class="w-100">
		<view class="flex-1 row-a-j-fc mt-8">
			<view class="integral-img">
				<image src="https://beichaung.createbei.com/files/common/extractgoldcoins.png" mode=""
					v-if="integral.types == 0"></image>
				<image src="https://beichaung.createbei.com/files/common/draw-money.png" mode="" v-if="integral.types == 1">
				</image>
			</view>
			<view class="mt-3 font-s-4 font-w" v-if="integral.types == 0">{{ integral.points_way | wayFilter }}</view>
			<view class="mt-3 font-s-4 font-w" v-if="integral.types == 1">提现扣除</view>
			<view class="mt-2 font-s-5 font-w text-main-color"><text class="mr-1">{{ integral.types == 0 ? '+' : '-' }}</text>{{ integral.points_num }}</view>
			<view class="mt-2 font-s-3 text-light-muted">{{ integral.created_time }}</view>
		</view>
	</view>
</template>

<script>
	import {
		integralDetailUrl
	} from '@/api/index';
	export default {
		data() {
			return {
				integralId: '',
				integral: ''
			}
		},
		filters: {
			wayFilter(way) {
				if (way === 0) {
					return '看广告获得'
				} else if (way === 1) {
					return '发布文章获得'
				} else if (way === 2) {
					return '点赞文章获得'
				} else if (way === 3) {
					return '收藏文章获得'
				}
			},
		},
		onLoad(options) {
			this.integralId = options.integralId
			console.log(options);
			this.token = uni.getStorageSync('token')
			if (this.token != '') {
				this.loginStatus = true
				this.getIntegralDetail()
			} else {
				this.loginStatus = false
			}
		},
		methods: {
			getIntegralDetail() {
				this.$R.get(integralDetailUrl + this.integralId + '/').then(res => {
					if (res.code == 200) {
						this.integral = res.data
						console.log(this.integral);
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.integral-img {
		width: 168rpx;
		height: 168rpx;
		border-radius: 50%;

		image {
			width: 168rpx;
			height: 168rpx;
			border-radius: 50%;
		}
	}
</style>